#ifndef FRACTION_H
#define FRACTION_H

#include <string>
#include <iostream>

#include <QString>
#include <QStringList>
#include <QtDebug>


class Fraction
{
private:
	quint64 m_Integer;
	quint64 m_Numerator;
	quint32 m_Denominator;

	bool m_Sign;
	bool m_IsZero;

	
	quint64 NWD(quint64 a, quint64 b);
	quint64 NWW(quint64 a, quint64 b);
	void normalize();

public:
	Fraction();
	Fraction(quint32 cnt, quint32 num, quint32 den, bool plus = true);	
	Fraction(QString f);	
	~Fraction();

	bool isZero();
	QString toString(); 
	void changeSign();

	friend std::istream& operator>>(std::istream &i, Fraction& w);
    friend std::ostream& operator<<(std::ostream &o, Fraction& w);

	Fraction& operator+(const Fraction& f);
	Fraction& operator-(const Fraction& f);
	Fraction& operator*(const Fraction& f);
	Fraction& operator/(const Fraction& f);
	
	Fraction& operator+=(const Fraction& f);
	Fraction& operator-=(const Fraction& f);
	Fraction& operator*=(const Fraction& f);
	Fraction& operator/=(const Fraction& f);

	bool operator==(const Fraction& f) const;
	bool operator!=(const Fraction& f) const;
	bool operator>(const Fraction& f) const;
	bool operator<(const Fraction& f) const;
	bool operator>=(const Fraction& f) const;
	bool operator<=(const Fraction& f) const;
};

#endif // FRACTION_H